package video.infrastructure.repository;

import video.domain.model.Video;
import video.domain.repository.VideoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public class VideoRepositoryImpl implements VideoRepository {

    private final JpaVideoRepository jpaRepo;

    @Autowired
    public VideoRepositoryImpl(JpaVideoRepository jpaRepo) {
        this.jpaRepo = jpaRepo;
    }

    @Override
    public Video save(Video video) {
        return jpaRepo.save(video);
    }

    @Override
    public void deleteById(Long videoId) {
        jpaRepo.deleteById(videoId);
    }

    @Override
    public Optional<Video> findById(Long videoId) {
        return jpaRepo.findById(videoId);
    }

    @Override
    public List<Video> findAll() {
        return jpaRepo.findAll();
    }

    @Override
    public List<Video> findByIsDeletedFalseOrderByCreateTimeDesc() {
        return jpaRepo.findByIsDeletedFalseOrderByCreateTimeDesc();
    }
}
